package main

import (
	"fmt"
	"net/http"

	"github.com/gin-gonic/gin"
)

func main() {

	r := gin.Default()
	r.GET("/posts", func(c *gin.Context) {
		c.String(http.StatusOK, "get")
	})
	r.POST("/posts", func(c *gin.Context) {
		c.String(http.StatusOK, "post")
	})
	r.PUT("/posts/:id", func(c *gin.Context) {
		c.String(http.StatusOK, fmt.Sprintf("put id:%s", c.Param("id")))
	})
	r.DELETE("/posts", func(c *gin.Context) {
		c.String(http.StatusOK, "delete")
	})
	// 所有请求类型都可以进
	r.Any("/users", func(c *gin.Context) {
		c.String(http.StatusOK, "any")
	})
	r.Run()

}
